#include <func.h>

void handler(int signo) {
	switch (signo) {
	case SIGINT:
		printf("Caught SIGINT\n");
		break;
	case SIGTSTP:
		printf("Caught SIGTSTP\n");
		break;
	default:
		printf("Unknown signal\n");
	}
}

int main(int argc, char* argv[])
{
	// 1. 注册信号处理函数
	sighandler_t oldhander = signal(SIGINT, handler);
	if (oldhander == SIG_ERR) {
		error(1, errno, "signal SIGINT");
	}

	oldhander = signal(SIGTSTP, handler);
	if (oldhander == SIG_ERR) {
		error(1, errno, "signal SIGTSTP");
	}

	// 2. 程序运行
	printf("pid = %d\n", getpid());
	printf("Programming running...\n");
	for(;;) {

	}
    return 0;
}

